package com.zzw.java.utils;

import lombok.Data;
import java.io.Serializable;


/**
 * @Author：hcy
 * @Package：com.zzw.java.serial.spring
 * @version：1.0
 * @Date：2025/8/6 14:02
 */


@Data
public class ResponseResult<T> implements Serializable {
    /**
     * responseCode : 成功默认为1
     */
    public static final int CODE_SUCCESS = 1;

    /**
     * responseCode : 失败默认为500
     */
    public static final int CODE_ERROR = 500;
    private Integer code;
    private String message;
    private T data;

    public ResponseResult(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public ResponseResult(Integer code, String message) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public static <T> ResponseResult<T> getSuccessResult(String message, T data) {
        return new ResponseResult<>(CODE_SUCCESS, message, data);
    }
    public static <T> ResponseResult<T> getSuccessResult(String message) {
        return new ResponseResult<>(CODE_SUCCESS, message);
    }
    public static <T> ResponseResult<T> getErrorResult(String message) {
        return new ResponseResult<>(CODE_ERROR, message);
    }
}
